Carbon


TextOrder

Header: StringCompare.h Carbon status: Supported

Compares two text strings, taking into account the script and language for each of the strings.

SInt16 TextOrder (
    const void *aPtr, 
    const void *bPtr, 
    SInt16 aLen, 
    SInt16 bLen, 
    ScriptCode aScript, 
    ScriptCode bScript, 
    LangCode aLang, 
    LangCode bLang
);
aPtr

A pointer to the first character of the first text string.

bPtr

A pointer to the first character of the second text string.

aLen

The length, in bytes, of the first text string.

bLen

The length, in bytes, of the second text string.

aScript

The script code for the first text string.

bScript

The script code for the second text string.

aLang

The language code for the first text string.

bLang

The language code for the second text string.

function result

Returns –1 if the first string is less than the second string, 0 if the first string is equal to the second string, and 1 if the first string is greater than the second string. The ordering of script and language codes, which is based on information in the script-sorting resource, is considered in determining the relationship of the two strings.0

DISCUSSION

This function takes both primary and secondary sorting orders into consideration and returns a value that indicates whether the first string is less than, equal to, or greater than the second string.

“Implicit Language Codes” are listed in the Constants section. Most applications specify the language code scriptCurLang for both the aLang and bLang values.

TextOrder first calls ScriptOrder; if the result of ScriptOrder is not 0 (that is, if the strings use different scripts), TextOrder returns the same result.

TextOrder next calls LanguageOrder; if the result of LanguageOrder is not 0 (that is, if the strings use different languages), TextOrder returns the same result.

At this point, TextOrder has two strings that are in the same script and language, so it compares them by using the sorting rules for that script and language, applying both the primary and secondary sorting orders. If that script is not installed and enabled, it uses the sorting rules specified by the system script or the font script, depending on the state of the international resources selection flag.

The TextOrder function is primarily used to insert text strings in a sorted list; for sorting, rather than using this function, it may be faster to sort first by script and language by using the ScriptOrder and LanguageOrder functions, and then to call the CompareText function, to sort strings within a script or language group.

SPECIAL CONSIDERATIONS

TextOrder may move memory; your application should not call this function at interrupt time.

AVAILABILITY

Supported in Carbon. Available in CarbonLib 1.0 and later. Exported by CarbonLib 1.0 and later.


© 2000 Apple Computer, Inc. — (Last Updated 4/14/2000)